<?php declare(strict_types=1);


namespace PinWuYun\domain\service\youZanServer;

use Exception;
use PinWuYun\domain\data\YouZanData\OrderData;
use Youzan\Open\Client;

/**
 * Created: by zhiJie
 * Date: 2021/6/29
 */
class OrderServer
{
    /**
     * 有赞确认发货接口
     * @param array $paramsPre
     * @param string $accessToken
     * @return mixed
     */
    public function confirmedSend(array $paramsPre, string $accessToken)
    {
        $client = new Client($accessToken);
        $method = 'youzan.logistics.online.confirm';
        $apiVersion = '3.0.0';
        return $client->post($method, $apiVersion, $paramsPre);
    }

    /**
     * 订单买家确认收货
     * @throws Exception
     */
    public function confirmedReceive(&$params)
    {
        $client = new Client(TokenServer::getAccessToken());
        $method = 'youzan.trade.confirm.receive.update';
        $apiVersion = '3.0.1';
        return $client->post($method, $apiVersion, [
            'yz_open_id' => $params['yz_open_id'],
            'tid' => $params['tid'],
        ]);
    }


}